const path = require('path');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
	entry:path.join(__dirname,'./src/main.js'),
	output:{
		path:path.join(__dirname,'./dist'),
		filename:'bundle.js'
	},
    plugins:[
        new VueLoaderPlugin(),
        new htmlWebpackPlugin({
            template: path.join(__dirname,'./src/index.html'),
            filename: 'index.html'
        }),
    ],
    // devServer:{
    //     open: true,
    //     port: 3000,
    //     contentBase: "src",
    //     hot: true
    // },
    // plugins:[
    //     //热更新模块对象
    //     new webpack.HotModuleReplacementPlugin(),
    // ],
    //配置所有第三方模块、加载器
    module:{
        rules:[
            //匹配以.css结尾的文件，用两个模块处理
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
            {test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
            {test:/\.(png|jpg|jpeg|bmp|gif)$/,use:['url-loader']},
            {test:/\.(ttf|woff|woff2|eot|svg)$/,use:['url-loader']},
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
            {test:/\.vue$/,use:'vue-loader'},
        ]
    },
    resolve:{
            alias:{
                "vue$":"vue/dist/vue.js"
            }
        }
}